package chances.system.operator.entity;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
@Table(name = "CS_SYS_ROLE")
@Proxy(lazy = false)
public class Role implements Serializable {

    private static final long serialVersionUID = -835118302946245746L;

    public static final int ID_ADMIN = 1;// 管理员
    
	public static final int STATUS_NORMAL = 0;
	public static final int STATUS_DELETED = -1;


    @Id
    @Column(name = "role_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(name="role_name")
    private String name;

    @Column(name = "role_desc")
    private String desc;
    
    
    @Column(name = "role_status")
    private Integer status;
  
    @JsonIgnore
    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(name = "CS_SYS_OPERATOR_ROLE",joinColumns={ @JoinColumn(name = "role_id") },
    		inverseJoinColumns = {@JoinColumn(name = "op_id")})
    private Set<Operator> operators= new LinkedHashSet<Operator>();
    
    public Role() {
    	this.status = STATUS_NORMAL;
    }

    public Role(String desc, String name) {
        this.desc = desc;
        this.name = name;
    	this.status = STATUS_NORMAL;
    }


    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

   


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

	public Long getId() {
		return id;
	}

	public Integer getStatus() {
		return status;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Set<Operator> getOperators() {
		return operators;
	}

	public void setOperators(Set<Operator> operators) {
		this.operators = operators;
	}

}
